<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
    <meta name="viewport" content="width=device-width,height=device-height">
    <link rel="stylesheet" href="<?php echo base_url().'public/home/' ?>css/general.css">
    <link rel="stylesheet" href="<?php echo base_url().'public/home/' ?>css/statistical.css?v=20210912">
    <script src="<?php echo base_url().'public/home/' ?>js/jquery-2.0.3.min.js"></script>
    <!-- 日期选择控件 -->
    <script src='<?php echo base_url().'public/home/mobile_date/' ?>jdate.min.js'></script>
    <!-- 下拉框 -->
    <?php include_once "public/home/html/mobile_select.php"  ?>
    <title>教师教学评价统计</title>
</head>
<body>
    <div class="top">
        <input type="hidden" name="url" id="url"value="<?php echo base_url() ?>">
        <input type="hidden" id="admin_id" value="<?=$_SESSION[SESS_USER_HOME]['id']?>">
        <div class='filter'>
            <div class="filter-item">
                <input type="text" id="date" onchange="getList(true)" value="" placeholder="选择日期"><img src="<?php echo base_url().'public/home/' ?>images/drop_down.png" alt="">
            </div>
            <!-- 管理员显示 -->
            <?php if($identity==1):?>
            <div class="filter-item">
                <input type="text" id="dept" onchange="getList(true)" placeholder="选择部门" readonly><img src="<?php echo base_url().'public/home/' ?>images/drop_down.png" alt="">
            </div>
            <?php endif?>
            <div class="filter-item">
                <input type="text" id="listen_type" onchange="getList(true)" placeholder="听课类型" readonly><img src="<?php echo base_url().'public/home/' ?>images/drop_down.png" alt="">
            </div>
            <div class="filter-item">
                <input type="text" id="type_char" onchange="getList(true)" placeholder="听课督导类型" readonly><img src="<?php echo base_url().'public/home/' ?>images/drop_down.png" alt="">
                <input type="hidden" id="type" >
            </div>
        </div>
        
    </div>
    <div class="min" id="min">
       
    </div>
    <div class="loading" style="text-align:center;"><img src="<?php echo base_url().'public/home/' ?>images/loading1.gif"></div>
    <div class="tip" style="display: none;">到底了,没有数据了~</div>



<script>

    
    let pageNo = 1;
    let pageSize = 20;
    let have = true;
    $(function () {
        getList();
        getOption()
        // 初始化日期控件
        new Jdate({
			  el: '#date',
			  format: 'YYYY-MM-DD',
			  beginYear: 2019,
			  endYear:  new Date().getFullYear(),              
				confirm: function(date) {
					$("#date").val(date)
                    getList(true)
				},
			})
        $(window).scroll(function(){
            // scroll at bottom
            if ($(window).scrollTop() + $(window).height() == $(document).height()) {
                pageNo++;
                getList()
            }
        });
    })

    function getList(change=false) {
        if(change){
            pageNo=1
            have=true
            $("#min").html('')
        }
        var date=$("#date").val() 
        if($("#date").val()=='请选择日期'){
            date='';
        }       
        console.log(date); 
        // $('.min').empty()

        $.ajax({
            url: $("#url").val()+"Home/Attend/teachingEvaluationStatistics",
            type: "post",
            dataType:'json',
            data: {
                    pageNo: pageNo,
                    pageSize: pageSize,
                    admin_id: $('#admin_id').val(),
                    type:$("#type").val(),
                    course_units:$("#dept").val(),
                    listen_type:$("#listen_type").val(),
                    created:date                   
                },

            success: function (res) {
                console.log(res);

                 let t= JSON.parse(res.v)
                 console.log(t);
                 var html = '';
                 if (t.length==0){
                    $(".loading").hide();
                    $(".tip").show();
                     return
                 }
                 if( status = true ){
                    if(t.count==0){
                            $(".loading").hide();
                            $(".tip").show();
                            return
                        }
                    $.each(t.ret, function (k, v) { 
                        
                        console.log('data',v);                      
                            
                        let a = (pageNo-1)*pageSize;

                        html+= `<div class="fk"><div class="name">
                                     <p id="name">${v.teacher_name}</p><p style="color:#616161;margin-left:2%"> ${v.teacher_code}</p>
                                   <div class="rtl">
                                     <img src="<?php echo base_url().'public/home/' ?>/images/score.png">
                                     <span id="results">${v.all_avg_score}</span>分</div></div>
                                   <div class="education">
                                     <span>${v.course_units}</span></div></div>`;

                      //数组
                        if(v.detail[0].type_info !=undefined){
                            html +=`<div class="fgx"></div>
                            <div class="xdd">
                            <div class="xddo">${v.detail[0].type_info}</div>
                            <div style="line-height:20px;display: inline;"><span class="spans sp" >平均得分：<span id="fs">${v.detail[0].avg_score}</span>分</span>
                            <span class="spans sp1">听课人次：<p id="rc">${v.detail[0].count}</p>人</span></div>
                            </div>`;
                            
                        }
                        if(v.detail[1]!=undefined){
                        html +=`<div class="fgx"></div>
                        <div class="xdd">
                        <span class="xddo">${v.detail[1].type_info}</span>
                        <div style="line-height:20px;display: inline;"><span class="spans sp">平均得分：<span id="fs">${v.detail[1].avg_score}</span>分</span>
                            <span class="spans sp1">听课人次：<p id="rc">${v.detail[1].count}</p>人</span></div>
                            </div></div>`;
                        }
                        if(v.detail[2]!=undefined){
                        html +=`<div class="fgx"></div>
                            <div class="xdd">
                            <span class="xddo">${v.detail[2].type_info}</span>
                            <div style="line-height:20px;display: inline;"><span class="spans sp">平均得分：<span id="fs">${v.detail[2].avg_score}</span>分</span>
                            <span class="spans sp1">听课人次：<p id="rc">${v.detail[2].count}</p>人</span></div>
                            </div></div>`;
                        }

                        
                        if( pageNo==t.totalPage){
                            have=false
                            $(".loading").hide();
                            $(".tip").show();
                        }
                    });
                    
                    $('#min').append(html);
                        
                  }else if( status = false ){
                    
                    $(".loading").hide();
                    $(".tip").show();

                  }
    
               },
        });
 }

 function detail (aid){
        console.log(aid);
        window.location.href = `<?php echo base_url() . 'Home/Attend/details/'?>${aid}`;
    }
    // 获取筛选项
    function getOption(){
        $.ajax({
            type: "post",
            url: $("#url").val()+"Home/Attend/teachingScreen",
            dataType: "json",
            success: function (data) {
                var t=JSON.parse(data.v)
                console.log(t);
                new MobileSelect({
                    trigger: '#listen_type',
                    title: '听课类型',
                    wheels: [
                                {data: t.listen_type}
                            ],
                    callback:function(indexArr, data){
                        $("#listen_type").val(data)
                        getList(true)
                    }
                });
                new MobileSelect({
                    trigger: '#dept',
                    title: '请选择部门',
                    wheels: [
                                {data: t.course_units}
                            ],
                    callback:function(indexArr, data){
                        $("#dept").val(data)
                        getList(true)
                    }
                });
                new MobileSelect({
                    trigger: '#type_char',
                    title: '请选择督导类型',
                    wheels: [
                                {data: t.type}
                            ],
                    callback:function(indexArr, data){
                        $("#type_char").val(data)
                        $("#type").val(parseInt(indexArr)+1)
                        getList(true)
                    }
                });
                
            }
        });
    }
</script>

</body>

</html>